<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
         <input type="text" v-focus>
    </div>
    <script src='https://cdn.jsdelivr.net/npm/vue@2.7.14/dist/vue.js'></script>
    <script>
        //全局自定义指令
        //Vue.directive("指令名字",选项);
        //局部自定义指令 在组件或者vue实例的选项中添加directives属性
        //比如，编写一个让input获取焦点的自定义指令
        Vue.directive("focus",{
            inserted(el,bind){
                console.log("el就是指令所在的dom元素");
                console.log(el);
                el.focus();
            }
        })
        const vm= new Vue({
            el:"#app",
            data:{},
            methods: {
                
            }
        })
    </script>
</body>
</html>